﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abcd.Warehouse.Domain.Commodities;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace Abcd.Warehouse.EFCore
{
    public class AbcdWarehouseDbContext : AbpDbContext<AbcdWarehouseDbContext>
    {
        internal DbSet<Commodity> Commodities { get; set; }

        public AbcdWarehouseDbContext(DbContextOptions<AbcdWarehouseDbContext> options) : base(options)
        {

        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
            builder.Entity<Commodity>(b =>
            {
                b.ToTable("FinishedCommodities");
                
                b.ConfigureByConvention();

                b.Property(x => x.Name).IsRequired().HasMaxLength(64);
                b.Property(x => x.Specification).IsRequired().HasMaxLength(128);
            });
        }
    }
}
